<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="ISO-8859-1"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="${pageContext.servletContext.contextPath}/styles/default.css" />
<link href="${JQueryCSS}" rel="stylesheet" type="text/css" />
<title>Insert title here</title>
</head>
<body>
<c:url value="/styles/ui-lightness/jquery-ui-1.8.18.custom.css" var="JQueryCSS" />
	
	<c:url value="/scripts/jquery-1.7.2.min.js" var="JQueryUrl" />
	<script src="${JQueryUrl}"> </script>
	<script>jQuery.noConflict();</script>

 	<c:url value="/scripts/jquery-ui-1.8.18.custom.min.js" var="JQueryUIUrl" />
  	<script src="${JQueryUIUrl}"> </script>
<!--
  	<c:url value="/javascript/discoveredFlights.js" var="discoverdFlightsUrl" />
	<script src="${discoverdFlightsUrl}"> </script>
 -->
 	<h1>Flight search</h1>
	<form id="fs_be_redo_model_Booking" action="/bookings">
		<h3>From: ${foundFlights.departure.region.name}
			${foundFlights.departure.name} ${foundFlights.departure.code}</h3>
		<h3>To: ${foundFlights.destination.region.name}
			${foundFlights.destination.name} [${foundFlights.destination.code}]</h3>
		<c:choose>
		<c:when test="${not empty foundFlights.flights}">
			<div id="startdatepicker"></div><div id="enddatepicker"></div>
			<h3>Flights</h3>
			<table>
				<thead>
					<tr>
						<th>Flight</th>
						<th>Departure time</th>
						<th>Flight duration</th>
						<th>Price</th>
						<th>Airline Company</th>
						<th>Order</th>
					</tr>
				</thead>
				<tbody>
				<c:forEach items="${foundFlights.flights}" var="flight"
					varStatus="status">
					<c:choose>
						<c:when test="${ status.first }">
							<c:set var="cssFirstRow" value="rowhighlight" />
						</c:when>
						<c:otherwise>
							<c:set var="cssFirstRow" value="" />
						</c:otherwise>
					</c:choose>
					<tr class="${cssFirstRow}">
						<td>${flight.flightCode}</td>
						<td>${flight.departureTime}</td>
						<td>${flight.duration}</td>
						<td>${flight.price}</td>
						<td>${flight.airlineCompany.name}</td>
						<c:url value="/bookings" var="bookFlightUrl">
							<c:param name="flight" value="${flight.flightId}" />
						</c:url>
						<td><a href="${bookFlightUrl}">Order</a></td>
					</tr>
				</c:forEach>
				</tbody>
			</table>
		</c:when>
		<c:otherwise>
		<h3>no flights found</h3>
		<p>
		<c:url value="/bookings?searchForm" var="retryUrl"/>
		<a href="${retryUrl }">Search again</a>
		</p>
		</c:otherwise>
		</c:choose>
	</form>
</body>
</html>